package com.three.controller;

import com.baor.baseUtil.R;
import com.three.domain.Leaves;
import com.three.service.LeavesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class LeavesController {
    @Autowired
    private LeavesService leavesService;
    @RequestMapping("/leavesListByStudent")
    public R leavesList(@RequestBody Map<String, Object> map){
        Integer id = (Integer) map.get("id");
        Integer pageIndex = (Integer) map.get("pageIndex");
        Integer pageSize = (Integer) map.get("pageSize");
        String date = (String) map.get("date");
        return leavesService.leavesList(id,pageIndex,pageSize,date);
    }
    // 添加请假记录
    @RequestMapping("/addLeavesByStudent")
    public R addLeaves(@RequestBody Leaves leaves){
        return leavesService.addLeaves(leaves);
    }



    //    查询待审批请假列表
    @RequestMapping("/getLeaves")
    public R getLeaves(@RequestBody Map<String, Object> map) {
        int pageIndex = (int) map.get("pageIndex");
        int pageSize = (int) map.get("pageSize");
        return leavesService.viewLeaves(pageIndex, pageSize) ;
    }
    //    操作审核请假
    @RequestMapping("/review")
    public String reviewLeave(@RequestBody Map<String, Object> params) {
        leavesService.reviewLeave(params); // 调用服务层方法
        return "审核状态已更新";
    }
}
